class Task18:
    def run(self, head, node_to_delete):
        if node_to_delete.next is not None:
            node_to_delete.val = node_to_delete.next.val
            node_to_delete.next = node_to_delete.next.next
            return head
        elif node_to_delete == head:
            return None
        else:
            node = head
            while node.next != node_to_delete:
                node = node.next
            node.next = node_to_delete.next
            return head
